<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="keywords" content="">
  <meta name="description" content="">
  <title>用户登录</title>
  <!-- 样 式 文 件 -->
  <link rel="stylesheet" th:href="@{component/pear/css/pear.css}"/>
  <link rel="stylesheet" th:href="@{admin/css/other/login.css}"/>
  <link rel="icon" href="admin/images/favicon.ico" type="image/x-icon"/>
  <style>
    .position-ableft50 {
      position: absolute;
      left: 50px;
    }

    .ml0 {
      margin-left: 0;
    }

    .logo {
      margin-top: 10px !important;
    }

    .title {
      margin-left: 6px !important;
    }
  </style>
</head>
<!-- 代 码 结 构 /admin/images/background.svg -->
<body background="" style="background-size: cover;">

<div class="layui-row" style="height: 290px">
  <div class="layui-col-md4">
    <div class="desc"></div>
  </div>
  <div class="layui-col-md4" style="padding-top: 120px;padding-left: 145px">
    <img class="logo" src="/admin/images/logo.png"/>
    <div class="title" style="color: #a4da3b !important;">Cheetah</div>
  </div>
  <div class="layui-col-md4">
    <div class="desc"></div>
  </div>
</div>
<div class="layui-row">
  <div class="layui-col-md4">
    <div class="desc"></div>
  </div>
  <div class="layui-col-md4">
    <div class="layui-panel" style="padding: 10px 20px;">
      <div class="layui-tab" lay-filter="tab1">
        <ul class="layui-tab-title">
          <li class="layui-this">用户登录</li>
          <!--          <li>用户注册</li>-->
          <!--          <li>维修登录</li>-->
        </ul>
        <div class="layui-tab-content">
          <div class="layui-tab-item layui-show">
            <form class="layui-form" action="javascript:void(0);" style="margin-top: 0px!important;">
              <div class="layui-form-item">
                <label class="layui-form-label position-ableft50">账户 :</label>
                <div class="layui-input-block ml0">
                  <input placeholder="admin" name="name" lay-verify="required" hover
                         class="layui-input"/>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label position-ableft50">密码 :</label>
                <div class="layui-input-block ml0">
                  <input placeholder="请输入" type="password" name="password" lay-verify="required"
                         hover
                         class="layui-input"/>
                </div>
              </div>
              <div class="layui-form-item">
                <button type="button" class="pear-btn pear-btn-success login down" lay-submit
                        lay-filter="login">
                  登 录
                </button>
              </div>
            </form>
          </div>
          <div class="layui-tab-item">
            <form class="layui-form" action="javascript:void(0);" style="margin-top: 0px!important;">
              <div class="layui-form-item">
                <input placeholder="请输入账户" lay-verify="required" hover class="layui-input"/>
              </div>
              <div class="layui-form-item">
                <input placeholder="请输入密码" lay-verify="required" hover class="layui-input"/>
              </div>
              <div class="layui-form-item">
                <input placeholder="请输入其他" lay-verify="required" hover class="layui-input"/>
              </div>
              <div class="layui-form-item">
                <button type="button" class="pear-btn pear-btn-danger register" lay-submit
                        lay-filter="register">
                  注 册
                </button>
              </div>
            </form>
          </div>
          <div class="layui-tab-item">
            维修登录
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="layui-col-md4">
    <div class="desc"></div>
  </div>

</div>


<!-- 资 源 引 入 -->
<script th:src="@{/component/layui/layui.js}"></script>
<script th:src="@{/component/pear/pear.js}"></script>
<script th:src="@{/admin/js/jquery.min.js}"></script>
<script th:src="@{component/my/const.js}"></script>

<script>
  layui.use(['form', 'button', 'popup', 'element'], function () {
    var form = layui.form;
    var button = layui.button;
    var popup = layui.popup;
    var element = layui.element;

    element.on('tab(tab1)', function (data) {
      console.log(this); //当前Tab标题所在的原始DOM元素
      // 改变网页标题
      $('title').html(this.innerHTML);
      // console.log(data.index); //得到当前Tab的所在下标
      // console.log(data.elem); //得到当前的Tab大容器
    });

    // 登 录 提 交
    form.on('submit(login)', function (data) {
      console.log("提交")
      /// 验证
      let btn = button.load({elem: '.login'});
      /// 登录
      $.ajax({
        url: suffix + '/admin/login',
        type: 'post',
        data: {name: data.field.name, password: data.field.password},
        dataType: 'json',
        success: function (res) {
          btn.stop(function () {
            if (res.code == 0) {
              popup.success(res.msg, function () {
                location.href = suffix + "/index";
              })
            } else {
              popup.failure(res.msg, function () {
              });
            }
          })

        }
      })
      return false;
    });
  })
</script>
</body>
</html>
